package com.five.community.service.impl;

import com.five.community.bean.Pet;
import com.five.community.bean.vo.PetVo;
import com.five.community.mapper.PetMapper;
import com.five.community.service.PetService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class PetServiceImpl implements PetService {
    @Autowired
    private PetMapper petMapper;

    @Override
    public List<PetVo> selectAllPet() throws Exception {
        return petMapper.selectAllPet();
    }

    @Override
    public void insert(Pet pet) throws Exception {
        petMapper.insert(pet);
    }

    @Override
    public void deleteById(long id) throws Exception {
        petMapper.delete(id);
    }

    @Override
    public List<PetVo> selectByName(String name) throws Exception {
        return petMapper.selectByName(name);
    }

    @Override
    public Pet selectById(long id) throws Exception {
        return petMapper.selectById(id);
    }

    @Override
    public void update(Pet pet) throws Exception {
        petMapper.update(pet);
    }

    @Override
    public List<PetVo> selectAllPets(Integer pageNum, Integer pageSize) throws Exception {
        PageHelper.startPage(pageNum,pageSize);
        return petMapper.selectAllPet();
    }

    @Override
    public List<PetVo> selectAllByName(Integer pageNum, Integer pageSize, String name) throws Exception {
        PageHelper.startPage(pageNum,pageSize);
        return petMapper.selectByName(name);
    }
}
